{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import ee\n",
    "import geemap"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "geemap.show_youtube('nAzZjKKd4w0')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "You can simply copy and paste your GEE JavaScripts into a code block wrapped with trip quotes and pass it to a variable. \n",
    "\n",
    "For example, you can grap GEE JavaScripts from [GEE Documentation](https://developers.google.com/earth-engine/image_visualization)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "js_snippet = \"\"\"\n",
    "// Load an image.\n",
    "var image = ee.Image('LANDSAT/LC08/C01/T1_TOA/LC08_044034_20140318');\n",
    "\n",
    "// Define the visualization parameters.\n",
    "var vizParams = {\n",
    "  bands: ['B5', 'B4', 'B3'],\n",
    "  min: 0,\n",
    "  max: 0.5,\n",
    "  gamma: [0.95, 1.1, 1]\n",
    "};\n",
    "\n",
    "// Center the map and display the image.\n",
    "Map.setCenter(-122.1899, 37.5010, 10); // San Francisco Bay\n",
    "Map.addLayer(image, vizParams, 'false color composite');\n",
    "\n",
    "\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "geemap.js_snippet_to_py(js_snippet, add_new_cell=True, import_ee=True, import_geemap=True, show_map=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "js_snippet = \"\"\"\n",
    "\n",
    "// Load an image.\n",
    "var image = ee.Image('LANDSAT/LC08/C01/T1_TOA/LC08_044034_20140318');\n",
    "\n",
    "// Create an NDWI image, define visualization parameters and display.\n",
    "var ndwi = image.normalizedDifference(['B3', 'B5']);\n",
    "var ndwiViz = {min: 0.5, max: 1, palette: ['00FFFF', '0000FF']};\n",
    "Map.addLayer(ndwi, ndwiViz, 'NDWI', false);\n",
    "\n",
    "\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "geemap.js_snippet_to_py(js_snippet)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "js_snippet = \"\"\"\n",
    "\n",
    "// Load 2012 MODIS land cover and select the IGBP classification.\n",
    "var cover = ee.Image('MODIS/051/MCD12Q1/2012_01_01')\n",
    "  .select('Land_Cover_Type_1');\n",
    "\n",
    "// Define a palette for the 18 distinct land cover classes.\n",
    "var igbpPalette = [\n",
    "  'aec3d4', // water\n",
    "  '152106', '225129', '369b47', '30eb5b', '387242', // forest\n",
    "  '6a2325', 'c3aa69', 'b76031', 'd9903d', '91af40',  // shrub, grass\n",
    "  '111149', // wetlands\n",
    "  'cdb33b', // croplands\n",
    "  'cc0013', // urban\n",
    "  '33280d', // crop mosaic\n",
    "  'd7cdcc', // snow and ice\n",
    "  'f7e084', // barren\n",
    "  '6f6f6f'  // tundra\n",
    "];\n",
    "\n",
    "// Specify the min and max labels and the color palette matching the labels.\n",
    "Map.setCenter(-99.229, 40.413, 5);\n",
    "Map.addLayer(cover,\n",
    "             {min: 0, max: 17, palette: igbpPalette},\n",
    "             'IGBP classification');\n",
    "\n",
    "\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "geemap.js_snippet_to_py(js_snippet)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
